<?php
	$username = $_POST["username"];
	$password = $_POST["password"];
	if($username != "" && $password != "")
		connect_database();
	else
		echo "<p>Input Missing</p>";

	function connect_database(){
		$mysqli = new mysqli('localhost', 'root', '', 'gluphien');
		if ($mysqli->connect_errno)
			echo "<p>Connection Failed.</p>";
		$found = false;
		$SQLstring = "SELECT userID, username, password FROM `gluphien`.`users`";
		if($result = $mysqli->query($SQLstring)){
			while(($Row = $result->fetch_row()) && $found == false) {
				if($GLOBALS["username"] == $Row[1] && $GLOBALS["password"] == $Row[2])
				{
					$userID = $Row[0];
					$found = true;
				}
			}
		}
		if($found)
			echo $userID;
		else
			echo "<p id='failed'>Incorrect</p>";
	}
?>